<!doctype html>
<html lang="zh-CN" th:replace="admin-layout :: layout(~{::title}, ~{}, ~{::script}, ~{::body}, 'exam-list')"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${id}?'修改考试':_">添加考试</title>
    <script th:inline="javascript">
        $("#submitBtn").click(function () {
            var loginName = $("input[name='name']").val();
            if (!loginName) {
                msgAlert("请输入考试名称")
                return;
            }
            var beginTime = $("input[name='startTime']").val();
            if (!beginTime) {
                msgAlert("请输入开始时间")
                return;
            }
            ajaxJson("/admin/exam/ajax/save", $("#form").serialize(), function (res) {
                if (res.status) {
                    location.href = "/admin/exam/list";
                }
            })
        })

        //选择图片
        $("#selImgBtn").click(function(){
            openWindow('选择图片',"/admin/select/image");
        })

        //填充图片
        function fillImage(image){
            $("#imageId").val(image.id);
            $("#imageUrl").attr("src",image.url)
            $("#imageUrl").parent().removeClass("hidden")
        }
    </script>
</head>
<body>
<!--<ol class="breadcrumb">
    <li><a th:href="@{/admin/exam/list}">考试列表</a></li>
    <li class="active"th:text="${data}?'修改考试':_">添加考试</li>
</ol>-->
<form class="form-horizontal" id="form">
    <input type="hidden" name="id" th:if="${data}" th:value="${data.id}">
    <input type="hidden" name="imageId" id="imageId" th:value="${data}?${data.imageId}">
    <div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>考试名称</label>
        <div class="col-sm-8 col-md-8 col-lg-6">
            <input type="text" class="form-control" placeholder="考试名称" name="name" th:value="${data}?${data.name}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>考试时间</label>
        <div class="col-sm-4 col-md-4 col-lg-3">
            <input type="text" class="form-control datetime" placeholder="开始时间" name="startTime" id="startTime"
                   readonly th:value="${data}?${#dates.format(data.startTime,'yyyy-MM-dd HH:ss:mm')}">
        </div>
        <div class="col-sm-4 col-md-4 col-lg-3">
            <input type="text" class="form-control datetime" placeholder="结束时间" name="endTime" id="endTime"
                   readonly th:value="${data}?${#dates.format(data.endTime,'yyyy-MM-dd HH:ss:mm')}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>简单说明</label>
        <div class="col-sm-8 col-md-8 col-lg-6">
            <input type="text" class="form-control" placeholder="简单说明" name="description" th:value="${data}?${data.description}">
        </div>
    </div>
    <!--<div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>封面图片</label>
        <div class="col-sm-8 col-md-8 col-lg-6">
            <button type="button" class="btn btn-default" id="selImgBtn">选择图片</button>
            <div class="fyl-mt10" th:classappend="${data}==null?'hidden'">
                <img th:src="${data}?${frdn}+${data.imageUrl}" id="imageUrl" class="img-thumbnail">
            </div>
        </div>
    </div>-->
    <div class="form-group">
        <div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-3 col-sm-8 col-md-8 col-lg-6">
            <button type="button" class="btn btn-primary" id="submitBtn">提交</button>
            <button type="button" class="btn btn-warning backBtn">返回</button>
        </div>
    </div>
</form>
</body>
</html>